package com.fangshicai.config;

import com.fangshicai.interceptor.RedisUrlInterceptor;
import com.fangshicai.interceptor.loginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置loginInterceptor类
 *1.实现WebMvcConfigurer类
 * 2.重写addInterceptors方法
 * @ClassName loginMvcInterceptor
 * @Description TODO
 * @Author fangshicai
 * @Date 2021/7/17 10:59
 */
@Configuration
public class loginMvcInterceptor implements WebMvcConfigurer {

    @Autowired
    RedisUrlInterceptor redisUrlInterceptor;

    //	public InterceptorRegistration addInterceptor(HandlerInterceptor interceptor) {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new loginInterceptor())
                .addPathPatterns("/**")//要拦截的路径
                .excludePathPatterns("/login","/","/css/**","/fonts/**","/images/**","js/**")//放行
        ;
        registry.addInterceptor(redisUrlInterceptor).addPathPatterns("/**")//要拦截的路径
                .excludePathPatterns("/login","/","/css/**","/fonts/**","/images/**","/js/**")//放行
    ;
    }
}
